package com.hnevc.music;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;



import java.util.List;

public class MyAdapter extends BaseAdapter {
    private Context context;
    private List<Music> musicList;

    public MyAdapter(Context context, List<Music> musicList) {
        this.context = context;
        this.musicList = musicList;
    }

    @Override
    public int getCount() {
        return musicList.size();
    }

    @Override
    public Object getItem(int position) {
        return musicList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        convertView = View.inflate(context, R.layout.item, null);

        TextView musicIdTv = convertView.findViewById(R.id.music_id_tv);
        musicIdTv.setText(musicList.get(position).getId());
        TextView musicNameTv = convertView.findViewById(R.id.music_name_tv);
        musicNameTv.setText(musicList.get(position).getMusicName());
        TextView musicSinger = convertView.findViewById(R.id.music_singer);
        musicSinger.setText(musicList.get(position).getSinger());

        return convertView;
    }
}
